﻿Imports System.Runtime.InteropServices

Public Class frmDebug
    Dim ParseHTML As New clsParseHTML
    Dim is_stop As Boolean = False

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate("https://m.facebook.com/groups/236891893140383?_rdr")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ParseHTML.SetSubmitByClassname(WebBrowser1, "bj")
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Debug.Print(ParseHTML.getByName(WebBrowser1.DocumentText, "input", "access_token", "value")(0).ToString)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        WebBrowser1.Navigate("https://m.facebook.com/v2.1/dialog/oauth?response_type=token&client_id=145634995501895&redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer%2Fcallback&scope=user_about_me%2Cuser_actions.books%2Cuser_actions.music%2Cuser_actions.news%2Cuser_actions.video%2Cuser_activities%2Cuser_birthday%2Cuser_education_history%2Cuser_events%2Cuser_friends%2Cuser_games_activity%2Cuser_groups%2Cuser_hometown%2Cuser_interests%2Cuser_likes%2Cuser_location%2Cuser_photos%2Cuser_relationship_details%2Cuser_relationships%2Cuser_religion_politics%2Cuser_status%2Cuser_tagged_places%2Cuser_videos%2Cuser_website%2Cuser_work_history%2Cemail%2Cmanage_notifications%2Cmanage_pages%2Cpublish_actions%2Cread_friendlists%2Cread_insights%2Cread_mailbox%2Cread_page_mailboxes%2Cread_stream%2Crsvp_event", Nothing, Nothing, "User-Agent: mobile\r\n")
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

    End Sub

    Private Sub WebBrowser1_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating


        If (WebBrowser1.Url IsNot Nothing And is_stop = False) Then
            Debug.Print(WebBrowser1.Url.ToString)
            If (InStr(WebBrowser1.Url.ToString, "#access_token=", CompareMethod.Text) > 0) Then
                Dim a As String
                a = Replace(WebBrowser1.DocumentText, "<script>", "")
                WebBrowser1.DocumentText = "a"
                is_stop = True
                e.Cancel = True
            End If
        Else
            is_stop = False
        End If
        Application.DoEvents()
    End Sub

    Private Sub WebBrowser1_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
        e.Cancel = True
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

    End Sub
End Class